﻿using Newtonsoft.Json;
using System.Web.Mvc;

namespace QunProject.Web.Controllers
{
    public class ReplyController : BaseController
    {
        /// <summary>
        /// 评论一个文章或回复某人
        /// </summary>
        /// <param name="articleId">文章ID</param>
        /// <param name="replyId">回复ID（回复某人）</param>
        /// <param name="content">内容</param>
        /// <returns></returns>
        public JsonResult EditReplyResult(int articleId, int? replyId, string content)
        {
            var paras = WeaveParameters<ReplyController>("EditReplyResult");
            var result = HttpPost("EditReplyResult", JsonConvert.SerializeObject(paras));
            return Json(result);
        }

        /// <summary>
        /// 点赞/踩
        /// </summary>
        /// <param name="type">类型 1|点赞 其他|踩</param>
        /// <param name="replyId">文章ID</param>
        /// <returns></returns>
        public JsonResult EditReplyPraiseCriticismResult(int type, int replyId)
        {
            var paras = WeaveParameters<ReplyController>("EditReplyPraiseCriticismResult");
            var result = HttpPost("EditReplyPraiseCriticismResult", JsonConvert.SerializeObject(paras));
            return Json(result);
        }

        /// <summary>
        /// 获取回复列表
        /// </summary>
        /// <param name="articleId">文章ID</param>
        /// <param name="page">页索引</param>
        /// <param name="limit">页大小</param>
        /// <param name="sort">排序 0|最新 1|最热</param>
        /// <returns></returns>
        public JsonResult GetReplyListResult(int articleId, int page = 1, int limit = 10, int sort = 0)
        {
            var paras = WeaveParameters<ReplyController>("GetReplyListResult");
            var result = HttpPost("GetReplyListResult", JsonConvert.SerializeObject(paras));
            return Json(result);
        }
    }
}